<template>
  <HomePanel ref="target" title="人气推荐" subTitle="人气爆款 不容错过">
    <template #right>
      <XtxMore />
    </template>
    <template #default>
      <HomeGoodList :goodList="hotList" />
    </template>
  </HomePanel>
</template>

<script>
import HomePanel from './home-panel.vue'
import HomeGoodList from './home-good-list.vue'
import { findHot } from '@/api/home'
import { ref } from 'vue'
// 导入全局公用的钩子函数
import { useObserver } from '@/hooks'

export default {
  name: 'HomeRecom',
  components: {
    HomePanel,
    HomeGoodList
  },
  setup () {
    const hotList = ref([])
    // 获取人气推荐数据
    const getHotList = async () => {
      const { result } = await findHot()
      hotList.value = result
    }

    const { target } = useObserver(getHotList)

    return { hotList, target }
  }
}
</script>

<style scoped lang='less'>
</style>
